//
//  UIView+LoginToast.m
//  GSCalendar
//
//  Created by guoshikeji_a on 2018/9/6.
//  Copyright © 2018年 tanyin. All rights reserved.
//

#import "UIView+LoginToast.h"

static NSInteger UIViewLoginToastTag = 100201;

@implementation UIView (LoginToast)

- (void)showLoginToast {
    GSCommonLoginToastView *view = [self viewWithTag:UIViewLoginToastTag];
    if (!view) {
        view = [GSCommonLoginToastView new];
        view.tag = UIViewLoginToastTag;
        [self addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(self);
            make.width.height.mas_equalTo(self);
        }];
    }
    [view startAnimation];
}

- (void)showMainToast {
    GSCommonLoginToastView *view = [self viewWithTag:UIViewLoginToastTag];
    if (!view) {
        view = [GSCommonLoginToastView new];
//        view.backgroundColor = UIColor.whiteColor;
        view.tag = UIViewLoginToastTag;
        [self addSubview:view];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(self);
            make.width.height.mas_equalTo(self);
        }];
    }
    [view startAnimation];
}

- (void)hideLoginToast {
    GSCommonLoginToastView *view = [self viewWithTag:UIViewLoginToastTag];
    if (view) {
        [view stopAnimation];
        view.hidden = true;
        [view removeFromSuperview];
    }
}

@end
